﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepositoryFramework
{
	/// <summary>
	/// Class <see cref="IntArrayExtensions"/> define extensions to int[]
	/// </summary>
	public static class IntArrayExtensions
	{
		/// <summary>
		/// Convert array to the SQL parameter with comas.
		/// </summary>
		/// <param name="array">The array.</param>
		/// <returns></returns>
		public static string ToSqlParameter(this int[] array)
		{
			if (array != null && array.Length > 0)
			{
				var sb = new StringBuilder();
				for (int i = 0; i < array.Length; i++)
				{
					if (sb.Length > 0)
					{
						sb.Append(",");
					}
					sb.Append(array[i]);
				}
				return sb.ToString();
			}
			return null;
		}
	}
}
